﻿@model QuanLySanXuat.Models.OrderFormModels
@if (Model != null)
{
    <div id="form_body">
        <table id="tblMaterial">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã công thức nguyên vật liệu</span></th>
                    <th style="width: 150px;"><span>Mã nguyên vật liệu</span></th>
                    <th style="width: 140px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 100px;"><span>Mã phiếu xuất</span></th>
                    <th style="width: 100px;"><span>Giá xuất</span></th>
                </tr>
            </thead>

            <tbody id="insertRow">
                @if (Model.MaterialDetailFormModels != null)
                {
                    foreach (var item in Model.MaterialDetailFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="MaterialDetailID" name="MaterialDetailID" class="MaterialDetailID" value="@item.ID" />
                            <input type="text" id="MaterialDetailCode" name="MaterialDetailCode" class="txt1 codematerial code" value="@item.Code">
                        </td>
                        <td>
                            @Html.DropDownList("MaterialFormulaID", new SelectList(ViewData["MaterialFormula"] as IEnumerable<Data.Models.MaterialFormula>, "ID", "Code", @item.MaterialFormulaID),  new { @class = "span2 col-sm-1 form-control materialformulachange" })
                        </td>
                        <td>
                            @Html.DropDownList("MaterialID", new SelectList(ViewData["Material"] as IEnumerable<Data.Models.Material>, "ID", "Name", @item.MaterialID),  new { @class = "span2 col-sm-1 form-control materialID" })
                        </td>
                        <td>
                            @Html.DropDownList("MaterialDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            <input type="text" id="MaterialDetailQuantity" name="MaterialDetailQuantity" class="txt1 quantitymaterial quantity" value="@item.Quantity">
                        </td>
                        <td>
                            @Html.DropDownList("BillDetailID", new SelectList(ViewData["BillDetail"] as IEnumerable<Data.Models.BillOut>, "ID", "Code", @item.BillDetailID),  new { @class = "span2 col-sm-1 form-control billchange", @onchange="GetPrice(this)" })
                        </td>

                        <td>
                            <input type="text" id="Price" name="Price" class="txt1 pricematerial price" placeholder="0" value="@item.Price">
                        </td>
                    </tr>
                    }
                }

            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblTool">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã CT công cụ sản xuất</span></th>
                    <th style="width: 140px;"><span>Mã công cụ sản xuất</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 140px;"><span>Định mức khấu hao</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính DM</span></th>
                    <th style="width: 50px;"><span>Định mức</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                @if (Model.ToolDetailFormModels != null)
                {
                    foreach (var item in Model.ToolDetailFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="ToolDetailID" name="ToolDetailID" class="ToolDetailID" value="@item.ID" />
                            <input type="text" id="ToolDetailCode" name="ToolDetailCode" class="txt1 codeTool code" value="@item.Code">
                        </td>
                        <td>
                            @Html.DropDownList("ToolFormulaID", new SelectList(ViewData["ToolFormula"] as IEnumerable<Data.Models.ToolFormula>, "ID", "Code", @item.ToolFormulaID),  new { @class = "span2 col-sm-1 form-control desgingchange" })
                        </td>
                        <td>
                            @Html.DropDownList("ToolTypeID", new SelectList(ViewData["ToolType"] as IEnumerable<Data.Models.ToolType>, "ID", "Name", @item.ToolTypeID), new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            @Html.DropDownList("ToolDetailUOM1ID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOM1ID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            <input type="text" id="ToolDetailQuantity" name="ToolDetailQuantity" class="txt1 quantityTool quantity" value="@item.Quantity">
                        </td>
                        <td>
                            @Html.DropDownList("ToolNormID", new SelectList(ViewData["ToolNorm"] as IEnumerable<Data.Models.ToolNorm>, "ID", "Norm",@item.ToolNormID),  new { @class = "span2 col-sm-1 form-control norm",@onchange="GetNorm(this,'tblTool');" })
                        </td>
                        <td>
                            @Html.DropDownList("ToolDetailUOMID2", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID2),  new { @class = "span2 col-sm-1 form-control unit" })
                        </td>
                        <td>
                            <input type="text" id="ToolDetailNorm" name="ToolDetailNorm" class="txt1 normTool quantity unitNorm" value="@item.Norm">
                        </td>
                    </tr>
                     
                    }
                }

            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblLabour">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã CT công thợ</span></th>
                    <th style="width: 140px;"><span>Mã bậc thợ</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 140px;"><span>Mã định mức bậc thợ</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính định mức</span></th>
                    <th style="width: 50px;"><span>Định mức</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                @if (Model.LabourDetailFormModels != null)
                {
                    foreach (var item in Model.LabourDetailFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="LabourDetailID" name="LabourDetailID" class="LabourDetailID" value="@item.ID"/>
                            <input type="text" id="LabourDetailCode" name="LabourDetailCode" class="txt1 codeLabour code" value="@item.Code">
                        </td>
                        <td>
                            @Html.DropDownList("LabourFormulaID", new SelectList(ViewData["LabourFormula"] as IEnumerable<Data.Models.LabourFormula>, "ID", "Code", @item.LabourFormulaID),  new { @class = "span2 col-sm-1 form-control desgingchange" })
                        </td>
                        <td>
                            @Html.DropDownList("LevelID", new SelectList(ViewData["Labour"] as IEnumerable<Data.Models.WorkerLevel>, "ID", "Name", @item.LevelID),  new { @class = "span2 col-sm-1 form-control" })
                        </td>
                        <td>
                            @Html.DropDownList("LabourDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID),  new { @class = "span2 col-sm-1 form-control accesscorychange" })
                        </td>
                        <td>
                            <input type="text" id="LabourDetailQuantity" name="LabourDetailQuantity" class="txt1 quantityLabour quantity" value="@item.Quantity">
                        </td>
                        <td>
                            @Html.DropDownList("LevelNormID", new SelectList(ViewData["LabourNorm"] as IEnumerable<Data.Models.LevelNorm>, "ID", "Name", @item.LevelNormID),  new { @class = "span2 col-sm-1 form-control norm",@onchange="GetNorm(this,'tblLabour');" })
                        </td>
                        <td>
                            @Html.DropDownList("LabourDetailUOMID2", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID2),  new { @class = "span2 col-sm-1 form-control unit" })
                        </td>
                        <td>
                            <input type="text" id="LabourDetailNorm" name="LabourDetailNorm" class="txt1 normLabour unitNorm" value="@item.Norm">
                        </td>
                    </tr>
                    }
                }

            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblOther">
            <thead>
                <tr>
                    <tr>
                        <th style="width: 90px;"><span>Ký hiệu</span></th>
                        <th style="width: 150px;"><span>Mã CT chi phí khác</span></th>
                        <th style="width: 140px;"><span>Chi phí khác</span></th>
                        <th style="width: 100px;"><span>Đơn vị tính</span></th>
                        <th style="width: 50px;"><span>Số lượng</span></th>
                        <th style="width: 50px;"><span>Định mức</span></th>
                    </tr>
                </tr>
            </thead>
            <tbody id="insertRow">
                @if (Model.OtherCostDetailFormModels != null)
                {
                    foreach (var item in Model.OtherCostDetailFormModels)
                    { 
                    <tr>
                        <td>
                            <input type="hidden" id="OtherCostDetailID" name="OtherCostDetailID" class="OtherCostDetailID" value="@item.ID" />
                            <input type="text" id="OtherCostDetailCode" name="OtherCostDetailCode" class="txt1 codeOther code" value="@item.Code">
                        </td>
                        <td>
                            @Html.DropDownList("OtherCostFormulaID", new SelectList(ViewData["OtherCostFormula"] as IEnumerable<Data.Models.OtherCostFormula>, "ID", "Code", @item.OtherCostFormulaID), new { @class = "span2 col-sm-1 form-control othercost" })
                        </td>
                        <td>
                            @Html.DropDownList("OtherCostID", new SelectList(ViewData["OtherCost"] as IEnumerable<Data.Models.OtherCost>, "ID", "Name", @item.OtherCostID), new { @class = "span2 col-sm-1 form-control norm",@onchange="GetNorm(this,'tblOther');" })
                        </td>
                        <td>
                            @Html.DropDownList("OtherCostDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name", @item.UOMID), new { @class = "span2 col-sm-1 form-control unit" })
                        </td>
                        <td>
                            <input type="text" id="OtherCostDetailQuantity" name="OtherCostDetailQuantity" class="txt1 quantityOther quantity" value="@item.Quantity">
                        </td>
                        <td>
                            <input type="text" id="OtherCostDetailNorm" name="OtherCostDetailNorm" class="txt1 normOther unitNorm" value="@item.Norm">
                        </td>
                    </tr>
                    }
                }

            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div class="btn-group">
        <div class="btn-group">
            <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Lưu</button>
        </div>
    </div>
    <div class="btn-group">
        <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/Order';" class="btn btn-defaultxero">Hủy</button>
    </div>
}
else
{
 <div class="btn-group">
        <div class="btn-group">
            <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Lưu</button>
        </div>
    </div>
    <div class="btn-group">
        <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/Order';" class="btn btn-defaultxero">Hủy</button>
    </div>
}
@*
else
{
    
    <div id="form_body">
        <table id="tblMaterial">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã công thức nguyên vật liệu</span></th>
                    <th style="width: 150px;"><span>Mã nguyên vật liệu</span></th>
                    <th style="width: 140px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 100px;"><span>Mã phiếu xuất</span></th>
                    <th style="width: 100px;"><span>Giá xuất</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                <tr>
                    <td>
                        <input type="hidden" id="MaterialDetailID" name="MaterialDetailID" class="MaterialDetailID" />
                        <input type="text" id="MaterialDetailCode" name="MaterialDetailCode" class="txt1 codematerial code">
                    </td>
                    <td>
                        @Html.DropDownList("MaterialFormulaID", new SelectList(ViewData["MaterialFormula"] as IEnumerable<Data.Models.MaterialFormula>, "ID", "Code"), "Chọn CT nguyên vật liệu", new { @class = "span2 col-sm-1 form-control materialformulachange" })
                    </td>
                    <td>
                        @Html.DropDownList("MaterialID", new SelectList(ViewData["Material"] as IEnumerable<Data.Models.Material>, "ID", "Name"), "Mã nguyên vật liệu", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("MaterialDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="MaterialDetailQuantity" name="MaterialDetailQuantity" class="txt1 quantitymaterial quantity">
                    </td>
                    <td>
                        @Html.DropDownList("BillDetailID", new SelectList(ViewData["BillDetail"] as IEnumerable<Data.Models.BillOut>, "ID", "Code"), "Chọn phiếu xuất", new { @class = "span2 col-sm-1 form-control billchange" })
                    </td>

                    <td>
                        <input type="text" id="Price" name="Price" class="txt1 pricematerial price" placeholder="0">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblTool">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã CT công cụ sản xuất</span></th>
                    <th style="width: 140px;"><span>Mã công cụ sản xuất</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 140px;"><span>Mã định mức khấu hao</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính DM</span></th>
                    <th style="width: 50px;"><span>Định mức</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                <tr>
                    <td>
                        <input type="hidden" id="ToolDetailID" name="ToolDetailID" class="ToolDetailID" />
                        <input type="text" id="ToolDetailCode" name="ToolDetailCode" class="txt1 codeTool code">
                    </td>
                    <td>
                        @Html.DropDownList("ToolFormulaID", new SelectList(ViewData["ToolFormula"] as IEnumerable<Data.Models.ToolFormula>, "ID", "Code"), "Chọn CT công cụ SX", new { @class = "span2 col-sm-1 form-control desgingchange" })
                    </td>
                    <td>
                        @Html.DropDownList("ToolTypeID", new SelectList(ViewData["ToolType"] as IEnumerable<Data.Models.ToolType>, "ID", "Name"), "Chọn loại công cụ", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("ToolDetailUOM1ID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="ToolDetailQuantity" name="ToolDetailQuantity" class="txt1 quantityTool quantity">
                    </td>
                    <td>
                        @Html.DropDownList("ToolNormID", new SelectList(ViewData["ToolNorm"] as IEnumerable<Data.Models.ToolNorm>, "ID", "Norm"), "Chọn định mức", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("ToolDetailUOMID2", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="ToolDetailNorm" name="ToolDetailNorm" class="txt1 normTool quantity">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblLabour">
            <thead>
                <tr>
                    <th style="width: 90px;"><span>Ký hiệu</span></th>
                    <th style="width: 150px;"><span>Mã CT công thợ</span></th>
                    <th style="width: 140px;"><span>Mã bậc thợ</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính</span></th>
                    <th style="width: 50px;"><span>Số lượng</span></th>
                    <th style="width: 140px;"><span>Mã định mức bậc thợ</span></th>
                    <th style="width: 100px;"><span>Đơn vị tính định mức</span></th>
                    <th style="width: 50px;"><span>Định mức</span></th>
                </tr>
            </thead>
            <tbody id="insertRow">
                <tr>
                    <td>
                        <input type="hidden" id="LabourDetailID" name="LabourDetailID" class="LabourDetailID" />
                        <input type="text" id="LabourDetailCode" name="LabourDetailCode" class="txt1 codeLabour code">
                    </td>
                    <td>
                        @Html.DropDownList("LabourFormulaID", new SelectList(ViewData["LabourFormula"] as IEnumerable<Data.Models.LabourFormula>, "ID", "Code"), "Chọn công thức công thợ", new { @class = "span2 col-sm-1 form-control desgingchange" })
                    </td>
                    <td>
                        @Html.DropDownList("LevelID", new SelectList(ViewData["Labour"] as IEnumerable<Data.Models.WorkerLevel>, "ID", "Name"), "Chọn mã bậc thợ", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("LabourDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="LabourDetailQuantity" name="LabourDetailQuantity" class="txt1 quantityLabour quantity">
                    </td>
                    <td>
                        @Html.DropDownList("LevelNormID", new SelectList(ViewData["LabourNorm"] as IEnumerable<Data.Models.LevelNorm>, "ID", "Name"), "Chọn mã bậc thợ", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("LabourDetailUOMID2", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="LabourDetailNorm" name="LabourDetailNorm" class="txt1 normLabour norm">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div id="form_body">
        <table id="tblOther">
            <thead>
                <tr>
                    <tr>
                        <th style="width: 90px;"><span>Ký hiệu</span></th>
                        <th style="width: 150px;"><span>Mã CT chi phí khác</span></th>
                        <th style="width: 140px;"><span>Chi phí khác</span></th>
                        <th style="width: 100px;"><span>Đơn vị tính</span></th>
                        <th style="width: 50px;"><span>Số lượng</span></th>
                        <th style="width: 50px;"><span>Định mức</span></th>
                    </tr>
                </tr>
            </thead>
            <tbody id="insertRow">
                <tr>
                    <td>
                        <input type="hidden" id="OtherCostDetailID" name="OtherCostDetailID" class="OtherCostDetailID" />
                        <input type="text" id="OtherCostDetailCode" name="OtherCostDetailCode" class="txt1 codeOther code">
                    </td>
                    <td>
                        @Html.DropDownList("OtherCostFormulaID", new SelectList(ViewData["OtherCostFormula"] as IEnumerable<Data.Models.OtherCostFormula>, "ID", "Code"), "Chọn CT chi phí khác", new { @class = "span2 col-sm-1 form-control othercost" })
                    </td>
                    <td>
                        @Html.DropDownList("OtherCostID", new SelectList(ViewData["OtherCost"] as IEnumerable<Data.Models.OtherCost>, "ID", "Name"), "Chọn chi phí", new { @class = "span2 col-sm-1 form-control" })
                    </td>
                    <td>
                        @Html.DropDownList("OtherCostDetailUOMID", new SelectList(ViewData["UOM"] as IEnumerable<Data.Models.UOM>, "ID", "Name"), "Chọn đơn vị", new { @class = "span2 col-sm-1 form-control accesscorychange" })
                    </td>
                    <td>
                        <input type="text" id="OtherCostDetailQuantity" name="OtherCostDetailQuantity" class="txt1 quantityOther quantity">
                    </td>
                    <td>
                        <input type="text" id="OtherCostDetailNorm" name="OtherCostDetailNorm" class="txt1 normOther norm">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="cleardiv"></div>
    <div class="btn-group">
        <div class="btn-group">
            <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Lưu</button>
        </div>
    </div>
    <div class="btn-group">
        <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/Order';" class="btn btn-defaultxero">Hủy</button>
    </div>
}*@

